from EmpVoting.PythonUtils import enum

ScoringRulesEnum = enum("Plurality", "Borda")

class ScoringRules(object):
    '''
    classdocs
    '''

    @staticmethod
    def ApplyScoringRule(votingRule, prefOrderVector):
        utilityDict = {}
        
        if votingRule == ScoringRulesEnum.Plurality:
            if len(prefOrderVector) > 0:
                utilityDict[prefOrderVector[0]] = 1
                
                for pref in prefOrderVector[1:]:
                    utilityDict[pref] = 0
            
            
        elif votingRule == ScoringRulesEnum.Borda:
            curBordaScore = len(prefOrderVector) - 1
            
            for pref in prefOrderVector:
                utilityDict[pref] = curBordaScore
                curBordaScore -= 1
        else:
            print("Error - Unknown voting rule.")
            
        return utilityDict